package com.pinyougou.shop.controller;

import com.pinyougou.Result;
import com.pinyougou.pojo.TbGoods;
import com.pinyougou.sellergoods.service.GoodsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


@RestController
@RequestMapping("/goods")
public class GoodsController {
    @Autowired
    private GoodsService goodsService;

    @RequestMapping("/add")
    public Result insert (@RequestBody TbGoods goods){

        try{
            //String sellerId  = SecurityContextHolder.getContext().getAuthentication().getName();
            //goods.setSellerId(sellerId);
            goods.setAuditStatus("0");
            int num = goodsService.add(goods);
            if (num>0){
                return new Result(true,"保存成功");
            }
        }catch (Exception e){
            e.printStackTrace();
        }
        return new Result(false,"保存失败");
    }
}
